//
// Created by 123 on 2025/1/10.
//
#include "vector"
#include "algorithm"
#include "iostream"

//常用遍历方法：搬运transform

class TransForm{
public:
    int operator()(int val){
        return val;
    }
};

class MyPrint{
public:
    void operator()(int val){
        std::cout << val << std::endl;
    }
};

void test(){
    std::vector<int> v;
    for (int i = 0; i < 10; ++i) {
        v.push_back(i);
    }
    std::vector<int> targetVector;
    //给目标容器提前开辟空间
    targetVector.resize(v.size());
    std::transform(v.begin(),v.end(),targetVector.begin(),TransForm());
    std::for_each(targetVector.begin(),targetVector.end(),MyPrint());
}

int main151(){
    test();
    return 0;
}